<%@ page contentType="text/html; charset=UTF-8" %>
<%@page import="java.util.List"%>
<%@page import="java.util.Iterator"%>
<%@ page import="com.wlcorp.forcazamis.domain.message.MessageStaff" %>
<%@ page import="com.wlcorp.forcazamis.sys.permission.PermissionManager" %>
<%@ page import="com.wlcorp.forcazamis.sys.util.ContextUtil" %>
<%@ page import="com.wlcorp.forcazamis.domain.system.Staff" %>
<%
	List deliverList = (List)request.getAttribute("deliverList");
%>
<html>
<head>
	<title>已发送消息</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<meta http-equiv="Pragma" content="no-cache"><meta http-equiv="Cache-Control" content="no-cache"><meta http-equiv="Expires" content="0">
	<link href="${pageContext.request.contextPath}/css/css.css" rel=stylesheet>
	<link rel="stylesheet" href="${pageContext.request.contextPath}/css/pagetitle_css.css" type="text/css">
	<link rel="stylesheet" href="${pageContext.request.contextPath}/css/button_css.css" type="text/css">
	<script type="text/javascript">
    	function writeMessage(){
    		window.location = "${pageContext.request.contextPath}/message/writemessage.jsp";
    	}
    	function deleteRecord(){
    		if(confirm("确定删除？")){
    			for (var i = 0; i < document.getElementsByName("message").length; i++) {
   					if(document.getElementsByName("message")[i].checked){
   						var messageStaffId=document.getElementsByName("message")[i].value;
   						window.location = "${pageContext.request.contextPath}/message/messageManager.do?method=deleteMessageStaff&type=deliver&messageStaffId=" + messageStaffId;
   					}
  				}
    		}
    	}
    	function checkAll() {
  			for (var i = 0; i < document.getElementsByName("message").length; i++) {
   				document.getElementsByName("message")[i].checked = document.getElementById("ifAll").checked;
  			}
 		}
 		function readMessage(messageStaffId){
    		window.location = "${pageContext.request.contextPath}/message/messageManager.do?type=deliver&method=readMessage&messageStaffId="+messageStaffId;
    	}
    </script>
</head>
<body bgcolor="#FFFFFF" text="#000000">
  <center>
  	<table width="100%" border="0" cellspacing="0" cellpadding="0" height="30">
	    <tr> 
	      <td width="23" class="page_titlebar_head">&nbsp;</td>
	      
	    <td class="page_titlebar_bg">已发送消息列表</td>
	    </tr>
	</table>
	<br>
	<table width="90%" border="0" cellspacing="1" cellpadding="0" bgcolor="#999999">
          <tr bgcolor="#E7E7E7">
            <td class="bigtext" align="center">接收人</td>
            <td class="bigtext" align="center">主题</td>
            <td class="bigtext" align="center">日期</td>
            <td class="bigtext" align="center"><input type="checkbox" name="ifAll" id="ifAll" value="全选" onClick="checkAll()">全选</td>
          </tr>
          <% 
          	int index = 0;
          	for(Iterator iter = deliverList.iterator();iter.hasNext();){
          		MessageStaff messageStaff = (MessageStaff)iter.next();
          		Staff receiver=ContextUtil.getInstance().getStaffService().getStaffById(messageStaff.getReceiverId());
          		index++;
          %>
          <tr bgcolor="#ffffff" onmouseover="this.style.backgroundColor='#bbdffb';" onmouseout="this.style.backgroundColor='#ffffff'">
            <td class="td5px" width="10%" align="center"><%=receiver.getStaffName()%></td>
            <td class="td5px"><a id="deleteA" href="javascript:readMessage('<%=messageStaff.getId()%>')"><%=messageStaff.getMessage().getSubject()%></a></td>
            <td class="td5px" width="13%"><%=messageStaff.getMessage().getSendTime()%></td>
            <td align="center" class="td5px" width="5%">
            	<input type="checkbox" name="message" value="<%=messageStaff.getId()%>"/>
            </td>
		  </tr>
          <%}%>
          <tr bgcolor="#ffffff" onmouseover="this.style.backgroundColor='#bbdffb';" onmouseout="this.style.backgroundColor='#ffffff'">
            <td align="center"><b>共&nbsp;<font color="blue"><%=index%></font>&nbsp;条</b></td>
            <td align="center"><b>为了节省空间，加快速度，请及时删除无用的消息</b></td>
            <td align="center" class="td5px" colspan="2">
            	<a id="deleteA" href="javascript:deleteRecord()">删除选中</a>&nbsp;
            	<a id="modifyA" href="javascript:writeMessage()">撰写消息</a>&nbsp;
            </td>
		  </tr>
	</table>
  </center>
  <%out.print(PermissionManager.getInstance().checkSubPermission("6003",request));%>
  ${message}
</body>
</html>
<jsp:include page="../footer.jsp"/>